package com.timo.mail.constants;

import org.apache.commons.lang3.StringUtils;

/**
 * @Author: Timo
 * @Date: 2019/6/4 11:05
 * @Description: 邮件相关常量类
 */
public class MailConstants {

    /**
     * 邮件地址返回分隔符
     */
    public static final String ADDRESS_SEPARATOR = ";";

    /**
     * 邮件地址返回格式字符串如：123456<123456@qq.com>; 123456<123456@qq.com>,1234567<1234567@qq.com>
     */
    public static final String ADDRESS_RESULT = "%s<%s>";

    /**
     * 附件保存的路径
     */
    public static final String FILE_SAVE_PATH = "D:\\downFile\\mailSaveFile";



    /**
     * 文件夹类型
     */
    public enum FolderEnum{
        /**
         * 收件箱
         */
        INBOX("INBOX"),
        /**
         * 草稿箱
         */
        DRAFTS("DRAFTS"),
        /**
         * 发件箱
         */
        SENT("SENT"),
        /**
         * 垃圾邮箱
         */
        TRASH("TRASH");

        public String folder;

        FolderEnum(String folder) {
            this.folder = folder;
        }

        public static FolderEnum getFolderEnum(String folder) {
            if (StringUtils.isEmpty(folder)) {
                return SENT;
            }
            for (FolderEnum f : FolderEnum.values()) {
                if (f.folder.equals(folder.toUpperCase())) {
                    return f;
                }
            }
            return null;
        }
    }



    /**
     * 超时参数时间设置
     */
    public static class MailTimeOut{
        public static final Long TIMEOUT_1_SECOND       = 1_000L;
        public static final Long TIMEOUT_5_SECOND       = 5_000L;
        public static final Long TIMEOUT_10_SECOND      = 10_000L;
        public static final Long TIMEOUT_30_SECOND      = 30_000L;
        public static final Long TIMEOUT_60_SECOND      = 60_000L;
    }
}
